Partial Class pages_Orders_Order : Inherits CPage

#Region "Querystring"
    Public ReadOnly Property OrderId() As Integer
        Get
            Dim id As Integer = CWeb.RequestInt("orderId")
            If id = Integer.MinValue Then CSitemap.RecordNotFound("Order", id)
            Return id
        End Get
    End Property
#End Region

#Region "Members"
    Private m_order As COrder
#End Region

#Region "Data"
    Public ReadOnly Property [Order]() As COrder
        Get
            If IsNothing(m_order) Then
                Try
                    m_order = New COrder(OrderId)
                Catch
                    CSitemap.RecordNotFound("Order", OrderId)
                End Try
            End If
            Return m_order
        End Get
    End Property
#End Region

#Region "Event Handlers - Page"
    Protected Overrides Sub PageInit()
        MyBase.PageInit()

        'AddMenuSide("Order Reminders", CSitemap.Reminders(OrderId))
        AddMenuSide("Order Payments", CSitemap.PaymentsForOrder(OrderId))
    End Sub
    Protected Overrides Sub PageLoad()
        With Me.Order

            lnkOrderProductId.Text = .Product.ProductName
            lnkOrderProductId.NavigateUrl = CSitemap.ProductEdit(.OrderProductId)


            lnkOrderCustomerId.Text = .Customer.CustomerName
            lnkOrderCustomerId.NavigateUrl = CSitemap.Customer(.OrderCustomerId)

            txtOrderPriceHistorical.ValueMoney = .OrderPriceHistorical

            chkOrderIsPaid.Checked = .OrderIsPaid

            txtOrderCreated.Text = CUtilities.Timespan(.OrderCreated)
            txtOrderCreated.ToolTip = CUtilities.LongDateTime(.OrderCreated)

            'txtEmails.Text = CUtilities.CountSummary(.ReminderCount, "email", "none")
            'txtEmails.NavigateUrl = CSitemap.Reminders(.OrderId)

            txtPayments.Text = CUtilities.CountSummary(.PaymentCount, "payment", "none")
            txtPayments.NavigateUrl = CSitemap.PaymentsForOrder(.OrderId)
        End With
    End Sub
#End Region

End Class
